@page "/counter"
@using BlazorElectronTemplate.Data
@using Microsoft.AspNetCore.Mvc.RazorPages

<h1>Counter</h1>

<p>Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@inject TabContainer ContainerTab;
@code {
    private int currentCount = 0;
    protected override async Task OnInitializedAsync()
    {
        var page = ContainerTab.TabList.FirstOrDefault(x => x.Href == "counter");
        if (page.Page != null)
            currentCount = ((Counter)page.Page).currentCount;
        if (page != null)
            page.Page = this;
    } 
    private void IncrementCount()
    {
        currentCount++;
    }
}
